package com.metaverse.backend.service;

import com.metaverse.backend.domain.LiveGift;
import com.metaverse.backend.domain.PlayerData;
import com.metaverse.backend.dto.PageQuery;
import com.metaverse.backend.repo.LiveGiftRepo;
import com.metaverse.backend.repo.PlayerDataRepo;
import com.metaverse.backend.utils.JpaUtils;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * 观众数据
 */
@AllArgsConstructor
@Service
public class PlayerDataService {

    private PlayerDataRepo playerDataRepo;


    /**
     * 分页数据
     * @param pageQuery
     * @return
     */
    public Page<PlayerData> all(PageQuery pageQuery) {
        return playerDataRepo.findAll(JpaUtils.toSpecification(pageQuery, PlayerData.class),
                JpaUtils.toPageRequest(pageQuery));
    }


    public Optional<PlayerData> findBySecOpenid(String openid){
        return playerDataRepo.findBySecOpenid(openid);
    }

}
